package com.xiaochen.autohttpinvoker;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.TypeMismatchException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.*;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ClassPathBeanDefinitionScanner;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

import java.util.Set;

/**
 * 根据配置文件是否配置了下面的属性，如果配置了，那么就扫描对应的注解
* @author chenkangyong
* @date 2019/3/9 13:05
*/
@Configuration
@Slf4j
public class HttpInvokerAutoConfig{
    @Bean(name = "rpcProviderScanner")
    @ConditionalOnProperty(name = {"rpc.provider.baseUrl","rpc.provider.basePackage"})
    public RpcProviderScanner rpcProviderScanner(){
        log.info("开启RpcProvider注解扫描");
        return new RpcProviderScanner();
    }

    @Bean
    @ConditionalOnProperty(name = {"rpc.consumer.baseUrl","rpc.consumer.basePackage"})
    public RpcConsumerScanner rpcConsumerScanner(){
        log.info("开启RpcConsumer注解扫描");
        return new RpcConsumerScanner();
    }

}

